﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    
    <Style TargetType="{x:Type TabItem}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabItem}">
                    <Grid Margin="0,0,0,0">
                        <Border x:Name="Border"  Background="#FFEEEEEE" BorderBrush="Silver" BorderThickness="1,1,0,1">
                            <ContentPresenter x:Name="ContentSite" VerticalAlignment="Center" HorizontalAlignment="Center" ContentSource="Header" Margin="10,0,10,0" RecognizesAccessKey="True"/>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
						<Trigger Property="IsSelected" Value="True">
							<Setter Property="Panel.ZIndex" Value="100" />
							<Setter TargetName="Border" Property="Background" Value="#FFDDDDDD" />
							<Setter TargetName="Border" Property="BorderThickness" Value="1,1,1,.5" />
						</Trigger>
						<Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="Border" Property="Background" Value="#FFEEEEEE" />
                            <Setter TargetName="Border" Property="BorderBrush" Value="Black" />
                            <Setter Property="Foreground" Value="DarkGray" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
		<Setter Property="HeaderTemplate">
			<Setter.Value>
				<DataTemplate>
					<Border x:Name="grid" Background="Red">
						<ContentPresenter>
							<ContentPresenter.Content>
								<TextBlock Margin="4" FontSize="15" Text="{TemplateBinding Content}"/>
							</ContentPresenter.Content>
							<ContentPresenter.LayoutTransform>
								<RotateTransform Angle="270" />
							</ContentPresenter.LayoutTransform>
						</ContentPresenter>
					</Border>
					<DataTemplate.Triggers>
						<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type TabItem}},Path=IsSelected}" Value="True">
							<Setter TargetName="grid" Property="Background" Value="Green"/>
						</DataTrigger>
					</DataTemplate.Triggers>
				</DataTemplate>
			</Setter.Value>
		</Setter>
	</Style>
</ResourceDictionary>